package cz.mendelu.swi2.documents.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import cz.mendelu.swi2.documents.model.Document;
import cz.mendelu.swi2.documents.model.DocumentManager;
import cz.mendelu.swi2.documents.model.Version;

/**
 * Controller for document module.
 * 
 * @author Jakub Skrha, xskrha
 */
@Controller
public class DocumentsController
{
	
	/**
	 * Document manager.
	 */
	private DocumentManager documentManager;
	
	
	/**
	 * Constructor make document manager.
	 */
	public DocumentsController() {
		super();
		this.documentManager = new DocumentManager();
	}


	/**
	 * Document versions list.
	 */
	@RequestMapping("/document/version/list")
	public ModelAndView documentVersionList() {
		String message = "Hello document version list.";
		
		Document document = this.documentManager.fetchById(1);
		document = this.documentManager.loadVersionListForDocument(document);
		
		ModelAndView view =  new ModelAndView("document/VersionList");
		view.addObject("document", document);
		
		return view;
	}
	
}
